{extend name="base" /}
{block name="content"}
<script language="javascript" type="text/javascript" src="__STATIC__/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>cms</span>
            <span class="icon-angle-right"></span>
            <span>管理栏目</span>
            <span class="icon-angle-right"></span>
            <span>页面管理</span>
            <span class="icon-angle-right"></span>
            <span>{$info ? '编辑' : '添加'}页面</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                            <tr>
                                <th colspan="2">{$info ? '编辑' : '添加'}页面</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="15%"><label for="title">页面标题<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="title" id="title" placeholder="请输入广告标题" value="{$info.title}" /></td>
                            </tr>
                            <tr>
                                <td><label for="">页面分类<em>*</em></label></td>
                                <td>
                                    <div class="lay-select">
                                        <select name="category_id">
                                            <option value="0">请选择页面分类</option>
                                            {foreach name="categories" item="category"}
                                            <option value="{$category.id}"{if condition="$info['category_id'] eq $category['id']"} selected{/if}>{$category.name}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="">发布时间</label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="post_time" id="post_time" placeholder="请选择发布时间" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="{$info.post_time ?: date('Y-m-d H:i:s', time())}" readonly /></td>
                            </tr>
                            <tr>
                                <td><label for="">标题图片</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-pic" data-name="titlepic"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                                    <div class="m-pic">
                                        <ul>
                                            {:attach_html($info.titlepic, 'titlepic')}
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="">相关附件</label></td>
                                <td>
                                    <button type="button" class="layui-btn u-upload-file" data-name="file"><i class="layui-icon">&#xe67c;</i>上传附件</button>
                                    <div class="m-files">
                                        <ul class="m-jquery-sorted">
                                            {:attach_html(unserialize($info.file), 'file', 'file')}
                                        </ul>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="keywords">页面关键词</label></td>
                                <td><input type="text" class="u-ipt u-ipt-longer" name="keywords" id="keywords" placeholder="请输入页面关键词" value="{$info.keywords}" /></td>
                            </tr>
                            <tr>
                                <td><label for="smalltext">页面简介</label></td>
                                <td><div class="m-textarea"><textarea name="smalltext" class="u-tarea" id="smalltext" placeholder="请输入页面简介">{$info.smalltext}</textarea></div></td>
                            </tr>
                            <tr>
                                <td><label for="list_order">排序</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="list_order" id="list_order" placeholder="请输入排序值" value="{$info.list_order ?: 0}" /><span>值越大越排在前面</span></td>
                            </tr>
                            <tr>
                                <td><label for="">选择模板</label></td>
                                <td>
                                    <div class="lay-select m-select-longer">
                                        <select name="template">
                                            <option value="pages_show"{if condition="$info['template'] eq 'pages_show'"} selected{/if}>默认页面模板 - pages_show.html</option>
                                            <option value="pages_show1"{if condition="$info['template'] eq 'pages_show1'"} selected{/if}>默认页面模板 - pages_show1.html</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2"><label for="smalltext">页面内容<em>*</em></label></td>
                            </tr>
                            <tr>
                                <td colspan="2"><textarea name="content" style="width:100%;height:300px;visibility:hidden;">{$info.content}</textarea></td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="m-form-btn"><input type="hidden" name="id" value="{$info.id}"><button id="j_btn" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script src="__STATIC__/public/js/jquery-ui.min.js"></script>
{include file="public:upload"/}
{include file="public:editor"/}
<script>
    $(function(){
        $(".m-jquery-sorted").sortable({
            placeholder: '.ui-placeholder'
        });
    })
    KindEditor.ready(function(K) {
        var editor = K.create('textarea[name="content"]', {
    		allowFileManager: true,
            uploadJson: uploadJson,
            fileManagerJson: fileManagerJson,
            afterBlur: function () {
                this.sync();
            }
    	});
    });
</script>
{/block}